<template>
	<view class="business">
		<view class="head" :style="{height: pHeight + tHeight + 'px'}">
			<view class="xztitle" :style="[{height: pHeight + 'px', top: tHeight + 'px',lineHeight: pHeight + 'px'}]">
				员工详情
				<view class="iconfont icon-dayuhao1" @click="fanhui"></view>
			</view>
		</view>
		<view class="headtop clearfix" :style="{marginTop: pHeight + tHeight + 'px'}">
			<view class="left fl">
				{{info.nickname}}
			</view>
			<view class="right fr clearfix" @click="topage('/subpackageA/staff/add?id=' + staff_id)">
				<image :src="baseUrl + '/wximage/bianji.png'" class="fl"></image>
				<view class="name fl">编辑</view>
			</view>
		</view>
		<view class="nr">
			<view class="list">
				<view class="liebiao clearfix">
					<view class="left fl">联系人：</view>
					<view class="right fl">
						<view class="title">{{info.lxrname}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">联系电话：</view>
					<view class="right fl">
						<view class="title">{{info.mobile}}</view>
					</view>
				</view>
				<!-- <view class="liebiao clearfix">
					<view class="left fl">所在地：</view>
					<view class="right fl">
						<view class="title">{{info.full_address}}</view>
					</view>
				</view> -->
				<view class="liebiao clearfix">
					<view class="left fl">已关联商户：</view>
					<view class="right fl">
						<view class="title">{{info.shanghucount}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">已铺设备：</view>
					<view class="right fl">
						<view class="title">{{info.shebeicount}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">结算方式：</view>
					<view class="right fl">
						<view class="name" v-if="info.jsfangshi==1">D+0</view>
						<view class="name" v-if="info.jsfangshi==2">D+1</view>
						<view class="name" v-if="info.jsfangshi==3">D+7</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">创建时间：</view>
					<view class="right fl">
						<view class="name">{{info.created_at}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mendian">
			<view class="heads clearfix">
				<view class="left fl">
					<image :src="baseUrl + '/wximage/hktubiao.png'"></image>
					<view class="name">商户</view>
				</view>
				<view class="right fr" @click="topage('/subpackageA/staff/addbusiness?staff_id=' + staff_id)">
					<image :src="baseUrl + '/wximage/add.png'"></image>
					<view class="name">添加商户</view>
				</view>
			</view>
			<view class="shuju" v-if="list.length != 0">
				<view class="li clearfix" v-for="(item,index) in list" :key="index" @click="topage('/subpackageA/business/detail?bussinid=' + item.id)">
					<image :src="baseUrl + '/wximage/saoma.png'" class="fl"></image>
					<view class="cen fl">
						<text class="title" v-if="item.dividedstatus == 0">{{item.nickname}}</text>
						<text class="title" v-if="item.dividedstatus == 1">{{item.nickname}}（比例:{{item.divided}}%）</text>
						<text class="title" v-if="item.dividedstatus == 2">{{item.nickname}}（固定金额:{{item.divided}}元）</text>
						<!-- <text class="address">商户地址：{{item.full_address}}</text> -->
						<text class="time">签约时间：{{item.created_at}}</text>
					</view>
					<view class="bili" @click.stop="topage('/subpackageA/store/divide?bussinid=' + item.id)">分成比例</view>
				</view>
			</view>
			<view class="empty" v-else>
				<image :src="baseUrl + '/wximage/empty.png'"></image>
				<text>暂无商户数据</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: getApp().globalData.baseUrl,
				headerTop: 0,
				pHeight: 0,
				tHeight: 0,
				list: [],
				staff_id: '',
				info: {
					nickname: '',
					lxrname: '',
					mobile: '',
					full_address: '',
					shanghucount: '',
					shebeicount: '',
					jsfangshi: '',
					created_at: ''
				},
			}
		},
		onLoad(options) {
			// 头部距离
			let res = uni.getSystemInfoSync() ///微信api方法
			let titleH;
			if (res && res['system']) {
				// 判断是否是安卓操作系统 （标题栏苹果为44px,安卓为48px）
				if (res['system'].indexOf('Android') > 0) {
					titleH = 48
				} else {
					titleH = 46
				}
				this.headerTop = titleH + res['statusBarHeight']
				this.pHeight = titleH
				this.tHeight = res['statusBarHeight']
			}

			this.staff_id = options.staff_id; //员工id
			this.request({
				url: '/xcx/staffinfo',
				data: {
					staff_id: this.staff_id
				},
				method: "POST"
			}).then(res => {
				if (res.data.code == 200) {
					this.info = res.data.data;
				} else {
					uni.showToast({
						title: res.data.message,
						icon: 'none'
					})
				}
			})
		},
		onShow() {
			//获取商户列表
			this.request({
				url: '/xcx/staffbusinesslist',
				data: {
					staff_id: this.staff_id,
				},
				method: "POST"
			}).then(res => {
				if (res.data.code == 200) {
					this.list = res.data.data;
				} else {
					uni.showToast({
						title: '请求失败，请稍后再试',
						icon: 'none'
					})
				}
			})
		},
		methods: {
			topage(url) {
				uni.navigateTo({
					url
				})
			},
			fanhui() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.business {
		width: 100%;
		margin: 0 auto;
		height: 100vh;
		background: #f9f9ff;
		overflow-y: scroll;

		.head {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);

			.xztitle {
				position: fixed;
				left: 0%;
				top: 0;
				width: 100%;
				text-align: left;
				color: #333333;
				font-size: 32rpx;
				padding-left: 74rpx;
				font-weight: 700;

				.iconfont {
					position: absolute;
					top: 0;
					left: 30rpx;
					font-size: 44rpx;
				}
			}
		}

		.headtop {
			width: 100%;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);
			height: 300rpx;
			padding: 20rpx 40rpx 0;
			box-sizing: border-box;

			.left {
				font-size: 32rpx;
				color: #333333;
				font-weight: 700;
			}

			.right {
				width: 116rpx;
				height: 36rpx;
				line-height: 36rpx;
				text-align: center;
				background: #FFFFFF;
				border-radius: 24rpx;
				margin-top: 6rpx;

				image {
					width: 36rpx;
					height: 36rpx;
					margin-left: 10rpx;
					margin-right: 6rpx;
				}

				.name {
					font-size: 24rpx;
					color: #333333;
				}
			}
		}

		.nr {
			width: 90%;
			margin: 0 auto;
			z-index: 70;
			margin-top: -200rpx;
			box-shadow: rgba(223, 230, 255, 0.67) 0px 0px 6px;

			.list {
				width: 100%;
				background: #fff;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				padding: 40rpx 40rpx 10rpx;
				position: relative;

				.liebiao {
					margin-bottom: 30rpx;

					.left {
						font-size: 24rpx;
						color: #333333;
						width: 30%;
					}

					.right {
						width: 70%;

						.title {
							font-size: 24rpx;
							color: #333333;
						}

						.name {
							font-size: 24rpx;
							color: #5C88FA;
						}
					}
				}
			}
		}

		.mendian {
			width: 90%;
			margin: 0 auto;
			z-index: 70;
			margin-top: 30rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			box-shadow: rgba(223, 230, 255, 0.67) 0px 0px 6px;
			margin-bottom: 60rpx;

			.heads {
				width: 100%;
				padding: 24rpx 20rpx 0;
				box-sizing: border-box;

				.left {

					image {
						float: left;
						width: 40rpx;
						height: 40rpx;
						margin-top: -6rpx;
					}

					.name {
						font-size: 28rpx;
						color: #333333;
						float: left;
					}
				}

				.right {

					image {
						float: left;
						width: 40rpx;
						height: 40rpx;
						margin-top: -6rpx;
					}

					.name {
						font-size: 28rpx;
						color: #368BF8;
						float: left;
					}
				}
			}

			.shuju {
				width: 100%;
				padding: 30rpx 26rpx;
				box-sizing: border-box;

				.li {
					width: 100%;
					position: relative;
					padding-bottom: 20rpx;
					margin-bottom: 20rpx;
					border-bottom: 1rpx solid #F1F1F1;

					image {
						width: 120rpx;
						height: 120rpx;
					}

					.cen {
						width: 480rpx;
						margin-left: 20rpx;

						text {
							display: block;
						}

						.title {
							font-size: 28rpx;
							color: #333333;
							font-weight: 700;
							margin-bottom: 10rpx;
						}

						.address {
							font-size: 24rpx;
							color: #666666;
							margin-bottom: 6rpx;
						}

						.time {
							font-size: 24rpx;
							color: #999999;
						}
					}

					.bili {
						position: absolute;
						right: 0;
						bottom: 20rpx;
						width: 120rpx;
						height: 32rpx;
						line-height: 32rpx;
						text-align: center;
						background: #3B91F8;
						color: #FFFFFF;
						border-radius: 16rpx;
						font-size: 22rpx;
					}
				}

				.li:last-child {
					border: none;
					margin-bottom: 0;
				}
			}
		}

		.empty {
			width: 100%;
			margin: 20rpx auto 0;
			text-align: center;
			padding-bottom: 20rpx;

			image {
				width: 390rpx;
				height: 340rpx;
			}

			text {
				display: block;
				margin-top: 30rpx;
				font-size: 24rpx;
				color: #666666;
			}
		}
	}
</style>